package cn.wolfcode.luowowo.redis;

import cn.wolfcode.luowowo.util.Consts;
import lombok.Getter;

/**
 * 统一redis 的key管理
 */
@Getter
public enum RedisKeys {
    //用户登录key对象实例
    USER_LOGIN_TOKEN("user_login_token", Consts.USER_INFO_TOKEN_VAI_TIME * 60L);
    private String prefix;  //redis的key的前缀
    private Long time;      //redis的key的有效时间, 约定单位是 s

    RedisKeys(String prefix, Long time){
        this.prefix = prefix;
        this.time = time;
    }
    //拼接 redis的key
    public String join(String ... values){
        StringBuilder sb = new StringBuilder(50);
        sb.append(this.prefix);
        for (String v : values) {
            sb.append(":").append(v);
        }
        return sb.toString();
    }
}
